#include <crt_util.h>
#include <rpc.h>
#include <RpcNdr.h>
#pragma comment(lib, "rpcrt4.lib")
#include "rpcmsg.h"
#include "channel_h.h"

void __RPC_FAR* __RPC_USER midl_user_allocate(size_t len)
{
    void* ptr = NULL;
    HANDLE heap = GetProcessHeap();
    HeapLock(heap);
    HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, len);
    HeapUnlock(heap);
    return ptr;
}

void __RPC_USER midl_user_free(void __RPC_FAR* ptr)
{
    if (ptr != NULL) {
        HANDLE heap = GetProcessHeap();
        HeapLock(heap);
        HeapFree(GetProcessHeap(), 0, ptr);
        HeapUnlock(heap);
        ptr = NULL;
    }
}

error_status_t S_Channel_Ping(
    /* [in] */ handle_t IDL_handle)
{
    return S_OK;
}

error_status_t S_Channel_CheckSecurity(
    /* [in] */ handle_t IDL_handle)
{
    return S_OK;
}

error_status_t S_Channel_PostBroadcast(
    /* [in] */ handle_t IDL_handle,
    /* [in] */ GUID sg,
    /* [in] */ GUID source,
    /* [in] */ GUID target,
    /* [in] */ ULONG msgid,
    /* [in][size_is] */ BYTE* name,
    /* [in] */ UINT namelen,
    /* [size_is][in] */ BYTE* inmsg,
    /* [in] */ ULONG inlen)
{
    return S_OK;
}

error_status_t S_Channel_Post(
    /* [in] */ handle_t IDL_handle,
    /* [in] */ GUID sg,
    /* [in] */ GUID source,
    /* [in] */ GUID target,
    /* [in] */ ULONG msgid,
    /* [in][size_is] */ BYTE* name,
    /* [in] */ UINT namelen,
    /* [size_is][in] */ BYTE* inmsg,
    /* [in] */ ULONG inlen,
    /* [size_is][out] */ BYTE* outmsg,
    /* [out][in] */ ULONG* outlen)
{
    return S_OK;
}